import { BasicColumn, FormSchema } from "/@/components/Table";
import { render } from "/@/utils/common/renderUtils";
//import { h } from "vue";

const statusFmt = ({text}: { text: any }) => {
  const color = text == '0' ? 'red' : text == '1' ? 'green' : 'gray';
  return render.renderTag(render.renderDict(text, 'stateType'), color)
}

const bcCountFrm = ({text, record}) => {
  if (Number(record.bcCount) > 0) {
    return render.renderColor(text, 'text-red-500')//h('span', { style: {color:'red'} }, text)
  } else {
    return text;
  }
}

// function memberFrm({text, record}){
//   if (record.type == 2) {
//     if (text > 0) {
//       return render.renderTag('已注册', 'red');
//     } else {
//       return render.renderTag('未注册', 'green');
//     }
//   } else {
//     return text;
//   }
// }

//{ dataIndex: "member", title: "会员数", width: 60, align: "center", customRender: memberFrm },
export const columns: BasicColumn[] = [
  { dataIndex: "area_name", title: "资方/产品/等级", width: 250, align: "left", customRender: bcCountFrm, ellipsis: true },
  { dataIndex: "gxr", title: "操作人", width: 60, align: "center" },
  { dataIndex: "gxsj", title: "操作时间", width: 80, align: "center" },
  { dataIndex: 'stat', title: '状态',  width: 60, customRender: statusFmt},
  { dataIndex: "sort", title: "排序", width: 80, align: "right" }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'dataTable',
    label: '表名',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'dataId',
    label: '数据ID',
    component: 'Input',
    colProps: { span: 8 },
  },
];

//{ dataIndex: "member", title: "会员数", width: 60, align: "center", customRender: memberFrm },
export const departColumns: BasicColumn[] = [
  { dataIndex: "parentId", title: "类型", width: 60, align: "center", customRender: ({text}) => render.renderDict(text, 'customerDepart') },
  { dataIndex: "areaName", title: "名称", width: 150, align: "left", ellipsis: true },
  { dataIndex: "lrr", title: "操作人", width: 70, align: "center" },
  { dataIndex: "gxsj", title: "操作时间", width: 100, align: "center", format: 'date|YYYY-MM-DD HH:mm' },
];